<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <title>话题</title>
    <script src="js/js-bridge.js"></script>
    <script>
        (function () {
            function applyStyle(path) {
                var link = document.createElement('link')
                link.rel = 'stylesheet'
                link.href = path
                document.head.appendChild(link)
            }

            if (window.appBridge.isThemeDarkMode()) {
                applyStyle('css/github-markdown-dark.css')
                applyStyle('css/topic-dark.css')
            } else {
                applyStyle('css/github-markdown-light.css')
                applyStyle('css/topic-light.css')
            }
        })()
    </script>
</head>
<body>
<div id="app">
    <template v-if="topic">
        <div class="topic surface">
            <div class="title">{{topic.title}}</div>
            <div class="info">
                <div class="left">
                    <img class="avatar" :src="topic.author.avatar_url" :alt="topic.author.loginname">
                </div>
                <div class="center">
                    <div class="line">
                        <span class="tag-top" v-if="topic.top">置顶</span>
                        <span class="tag-tab" v-else>{{topic.tab}}</span>
                        <span class="login-name">{{topic.author.loginname}}</span>
                    </div>
                    <div class="line">
                        <span class="create-time-and-visit_count">{{topic.create_at}} · {{topic.visit_count}} 阅读</span>
                    </div>
                </div>
                <div class="right">

                </div>
            </div>
            <div class="content markdown-body" v-html="topic.content.html"></div>
        </div>
        <div class="empty surface" v-if="!topic.replies || topic.replies.length === 0">
            暂无评论
        </div>
        <div class="replies surface" v-else>
            <div class="info">
                <div class="count">评论 {{topic.replies.length}}</div>
            </div>
            <template v-for="(reply, index) in topic.replies">
                <div class="divider"></div>
                <div class="reply">
                    <div class="content markdown-body" v-html="reply.content.html"></div>
                </div>
            </template>
        </div>
        <div class="bottom-space"></div>
    </template>
</div>
<script src="js/vue.js"></script>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            accountId: null,
            topic: null
        },
        methods: {
            // TODO
        }
    })

    function updateAccountId(accountId) {
        app.accountId = accountId
    }

    function updateTopic(topic) {
        app.topic = topic
    }
</script>
<script src="js/token.js"></script>
<script src="js/topic-test.js"></script>
</body>
</html>
